Skip to content
This repository was archived by the owner on Oct 13, 2023. It is now read-only.

[19.03 backport] Use correct LOOP_CTL_GET_FREE API in pkg/loopback#347

Merged
thaJeztah merged 1 commit intodocker-archive:19.03from
kolyshkin:19.03-loopback-idx
Sep 6, 2019
Merged

[19.03 backport] Use correct LOOP_CTL_GET_FREE API in pkg/loopback#347
thaJeztah merged 1 commit intodocker-archive:19.03from
kolyshkin:19.03-loopback-idx

Conversation

@kolyshkin
Copy link
Copy Markdown

Backport of PR moby#39801


The ioctl interface for the LOOP_CTL_GET_FREE request on
/dev/loop-control is a little different from what unix.IoctlGetInt
expects: the first index is the returned status in r1, not an int
pointer as the first parameter.

Unfortunately we have to go a little lower level to get the appropriate
loop device index out, using unix.Syscall directly to read from
r1. Internally, the index is returned as a signed integer to match the
internal ioctl expectations of interpreting a negative signed integer
as an error at the userspace ABI boundary, so the direct interface of
ioctlLoopCtlGetFree can remain as-is.

[@kolyshkin: it still worked before this fix because of
/dev scan fallback in ioctlLoopCtlGetFree()]

The `ioctl` interface for the `LOOP_CTL_GET_FREE` request on
`/dev/loop-control` is a little different from what `unix.IoctlGetInt`
expects: the first index is the returned status in `r1`, not an `int`
pointer as the first parameter.

Unfortunately we have to go a little lower level to get the appropriate
loop device index out, using `unix.Syscall` directly to read from
`r1`. Internally, the index is returned as a signed integer to match the
internal `ioctl` expectations of interpreting a negative signed integer
as an error at the userspace ABI boundary, so the direct interface of
`ioctlLoopCtlGetFree` can remain as-is.

[@kolyshkin: it still worked before this fix because of
/dev scan fallback in ioctlLoopCtlGetFree()]

Signed-off-by: Daniel Sweet <danieljsweet@icloud.com>
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit db2bc43)
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
@thaJeztah thaJeztah added this to the 19.03.3 milestone Sep 6, 2019
Copy link
Copy Markdown
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

all green

@thaJeztah thaJeztah merged commit 81fcfc6 into docker-archive:19.03 Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants